package com.sduept.nwld.mobile.rest;

import com.sduept.bigdata.fault.entity.FaultRecord;
import com.sduept.nwld.mobile.manager.MessagePushManager;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * 手机端消息推送
 * @author Ningfw
 * @date 20171020
 *
 */
@Slf4j
@RestController
@RequestMapping("/messagePush/")
public class MessagePushService {

	@Autowired
	private MessagePushManager messagePushManager;
	

	@GetMapping("/getLoginParam/{loginId}")
	public void getLoginParam(@PathVariable("loginId") String loginId){
		String a = loginId;
		log.info(loginId);
	}
	

	@GetMapping("/faultReportPush")
	public void faultReportPush(){
		
		List<FaultRecord> cimList = new ArrayList<FaultRecord>();
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		String myDate = sdf.format(new Date());
		Date myDates = null;
		try {
			myDates = sdf.parse(myDate);
		} catch (ParseException e) {
			e.printStackTrace();
		}
		for(int i = 0; i < 1; i++){
			FaultRecord fr = new FaultRecord();
//			fr.setEquipment("景思甲线"+i);
////			fr.setEquipment_id(String.valueOf(Math.random()));
//			fr.setFaultTime(myDates);
//			fr.setFaultReson("雷击");
			cimList.add(fr);
		}
		messagePushManager.faultReportPush(cimList);
	}
}
